---
kind: ServiceAccount
apiVersion: v1
metadata:
  name: dns-autoscaler
  namespace: kube-system
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: system:dns-autoscaler
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["list", "watch"]
  - apiGroups: [""]
    resources: ["replicationcontrollers/scale"]
    verbs: ["get", "update"]
  - apiGroups: ["extensions", "apps"]
    resources: ["deployments/scale", "replicasets/scale"]
    verbs: ["get", "update"]
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["get", "create"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: system:dns-autoscaler
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
subjects:
  - kind: ServiceAccount
    name: dns-autoscaler
    namespace: kube-system
roleRef:
  kind: ClusterRole
  name: system:dns-autoscaler
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    k8s-app: dns-autoscaler
  name: dns-autoscaler
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: dns-autoscaler
  template:
    metadata:
      labels:
        k8s-app: dns-autoscaler
    spec:
      priorityClassName: system-cluster-critical
      serviceAccountName: dns-autoscaler
      nodeSelector:
        beta.kubernetes.io/os: linux
      tolerations:
        - effect: NoSchedule
          operator: Equal
          key: node-role.kubernetes.io/master
        - key: "CriticalAddonsOnly"
          operator: "Exists"
      containers:
      - command:
        - /cluster-proportional-autoscaler
        - --namespace=kube-system
        - --configmap=dns-autoscaler
        - --target=Deployment/coredns
        - --default-params={"linear":{"coresPerReplica":8,"nodesPerReplica":3,"min":1}}
        - --logtostderr=true
        - --v=2
        image: {{registry_prefix}}:{{registry_port}}/{{cluster_proportional_autoscaler_amd64_image}}:{{dns_version}}
        imagePullPolicy: IfNotPresent
        name: autoscaler
        resources:
          requests:
            cpu: 200m
            memory: 500Mi